import java.util.Scanner;

public class demo1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Long[] dp = new Long[21];
        dp[1] = 0L;
        dp[2] = 1L;
        for(int i = 3; i < dp.length; i++){
            dp[i] = (i-1)*(dp[i-1]+dp[i-2]);
        }
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            System.out.println(dp[n]);
        }
    }
}
